package com.object.module.lq.chatroom.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.object.module.lq.chatroom.entity.TChatHistory;
import com.object.module.lq.chatroom.service.TChatHistoryService;
import com.object.utils.Q;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;


/**
 * 聊天记录
 *
 * @author 小庆
 **/
@RestController
@RequestMapping("/chatroom/TChatHistory")
@Api(tags = "聊天记录接口")
public class TChatHistoryController
{
    @Autowired
    private TChatHistoryService service;


    @ApiOperation("列表")
    @GetMapping("/list")
    public Q list(@RequestParam Map
            <String, Object> params)
    {
        return service.listPage(params);
    }


    @ApiOperation("详情")
    @GetMapping("/info/{id}")
    public Q info(@PathVariable("id") String id)
    {
        TChatHistory bean = service.getById(id);
        return Q.ok().q("data", bean);
    }


    @ApiOperation("保存")
    @PostMapping("/save")
    public Object save(@RequestBody TChatHistory bean)
    {
        return Q.ok().q("data", service.save(bean));
    }

    @ApiOperation("修改根据id")
    @PostMapping("/update")
    public Object update(@RequestBody TChatHistory bean)
    {
        return Q.ok().q("data", service.updateById(bean));
    }

    @ApiOperation("批量操作")
    @PostMapping("/batchWord")
    public Object update(@RequestBody List<TChatHistory> beans)
    {
        return Q.ok().q("data", service.updateBatchById(beans));
    }

    @ApiOperation("删除根据id")
    @DeleteMapping("/delete")
    public Object delete(@RequestBody String[] ids)
    {
        return Q.ok().q("data", service.removeByIds(Arrays.asList(ids)));
    }
}